package com.mmg.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mmg.entity.User;
import com.mmg.mapper.UserMapper;
import com.mmg.service.UserService;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public User login(User user) {
        User token = null;
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("username", user.getUsername());
        User account = this.baseMapper.selectOne(wrapper);
        if (account != null) {
            if (user.getPassword().equals(account.getPassword())) {
                token = user;
                token.setId(account.getId());
            }
        }
        return token;
    }

}
